-
Notifications
You must be signed in to change notification settings - Fork 194
Propose API improvements to Calendar #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propose API improvements to Calendar #321
Conversation
39108a6
to
c4f166c
Compare
c4f166c
to
0d4b4ad
Compare
```swift | ||
extension Calendar { | ||
public enum Component : Sendable { | ||
// .. existing fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a useful commentary ?
// .. existing fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do this so it's clear we are not adding this Component
type as part of this proposal.
public func dates(startingAt start: Date, | ||
in range: Range<Date>? = nil, | ||
matching components: DateComponents, | ||
matchingPolicy: MatchingPolicy = .nextTime, | ||
repeatedTimePolicy: RepeatedTimePolicy = .first, | ||
direction: SearchDirection = .forward) -> some (Sequence<Date> & Sendable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation, ctrl + M
public func dates(startingAt start: Date, | |
in range: Range<Date>? = nil, | |
matching components: DateComponents, | |
matchingPolicy: MatchingPolicy = .nextTime, | |
repeatedTimePolicy: RepeatedTimePolicy = .first, | |
direction: SearchDirection = .forward) -> some (Sequence<Date> & Sendable) | |
public func dates( | |
startingAt start: Date, | |
in range: Range<Date>? = nil, | |
matching components: DateComponents, | |
matchingPolicy: MatchingPolicy = .nextTime, | |
repeatedTimePolicy: RepeatedTimePolicy = .first, | |
direction: SearchDirection = .forward) -> some (Sequence<Date> & Sendable | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Foundation code we don't typically split the arguments from the first line.
public func dates(startingAt start: Date, | ||
in range: Range<Date>? = nil, | ||
byAdding component: Calendar.Component, | ||
value: Int = 1, | ||
wrappingComponents: Bool = false) -> some (Sequence<Date> & Sendable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, ctrl + m
public func dates(startingAt start: Date, | |
in range: Range<Date>? = nil, | |
byAdding component: Calendar.Component, | |
value: Int = 1, | |
wrappingComponents: Bool = false) -> some (Sequence<Date> & Sendable) | |
public func dates( | |
startingAt start: Date, | |
in range: Range<Date>? = nil, | |
byAdding component: Calendar.Component, | |
value: Int = 1, | |
wrappingComponents: Bool = false) -> some (Sequence<Date> & Sendable | |
) |
public func dates(startingAt start: Date, | ||
in range: Range<Date>? = nil, | ||
byAdding components: DateComponents, | ||
wrappingComponents: Bool = false) -> some (Sequence<Date> & Sendable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public func dates(startingAt start: Date, | |
in range: Range<Date>? = nil, | |
byAdding components: DateComponents, | |
wrappingComponents: Bool = false) -> some (Sequence<Date> & Sendable) | |
public func dates( | |
startingAt start: Date, | |
in range: Range<Date>? = nil, | |
byAdding components: DateComponents, | |
wrappingComponents: Bool = false | |
) -> some (Sequence<Date> & Sendable) |
35a0a7e
to
14e972f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be proposal 0001
In macOS 14 / iOS 17,
Calendar
was rewritten entirely in Swift. One of the many benefits of this change is that we can now more easily create Swift-specificCalendar
API that feels more natural than the existingenumerate
methods. In addition, we are taking the opportunity to add a new field to theDateComponents
type to handle one case that was only exposed via the somewhat esoteric CoreFoundation APICFCalendarDecomposeAbsoluteTime
.